home *** CD-ROM | disk | FTP | other *** search
- Path: global.gc.net!sourcebbs!david.mohorn
- From: david.mohorn@sourcebbs.com (DAVID MOHORN)
- Newsgroups: comp.lang.c
- Subject: COLLEGE PROFESSORS! #2
- Message-ID: <8BEC555.02C70031C5.uuout@sourcebbs.com>
- Date: Tue, 16 Apr 96 22:45:00 -0500
- Distribution: world
- Organization: SelectiveSourceBBS VirginiaBeach (804)471 6776
- Reply-To: david.mohorn@sourcebbs.com (DAVID MOHORN)
- X-Newsreader: PCBoard Version 15.22
- X-Mailer: PCBoard/UUOUT Version 1.20
-
- For those who may have found my previous message entertaining to
- read--and totally absurd--here another from last week.
-
- We have a program that reads a sequential file (50 items or so) and
- placed these items in an array. Items can be added and deleted from the
- array. There is only one catch, however. If you delete an item, it
- really doesn't get deleted.
-
- This is the instructors way of deleting an item from an array:
-
- declare main_array variable for 50 elements
- declare del_array variable for 50 elements
-
- When an array item is deleted, clear the data within the array, place
- element number in del_array array.
-
- When an item is added to the main_array, first scan the del_array array
- to see if any items have been deleted. If so, use the value within the
- array to denote what element within the main_array can be used for this
- new data. If there are no deleted items in the del_array, add new item
- at end of main_array.
-
- Doesn't this technique make the least amount of sense!?!?!? Now instead
- of maintaining only one array constructs, you have to maintain two:
- main_array and del_array. This also requires twice as much memory!
-
- My solution in deleting an element is to simply shift all elements
- above the element being deleted down one element. When a new element is
- added, it is added to the end of the array. For this many items, there
- shouldn't be any noticeable delay. If it were say, 500 items, I'd might
- think about having a "flag" field with each array indicating whether it
- was active or or inactive and keying on the flag.
-
- When I mentioned my technique to the instructor, he said his way is
- easier to read! When I mentioned to him about how his program now
- requires more memory, he said "memory is cheap now days, so there is no
- concern about saving memory..."
-
- This is just the type of injudicious crap an instructor needs to be
- teaching future, potential programmers! With this instructor's
- mentality, no wonder code today is bloated and requires a Pentium
- processor to run!
-
- Does anyone else have any opinions or horror stories?
-
- RIME: ->1369 FIDO: (1:275/102) INTERNET: david.mohorn@sourcebbs.com
-
- ---
- * QMPro 1.53 * Spaghetti code is computer lingo for job security.
-
-
- ---
- This message originated from: ---------- Selective Source BBS
- ------- Virginia Beach, Virginia
- ----- (804) 471 6776
-